import { SHOW_MENU, HIDE_MENU, CHANGE_MENU_TITLE } from '../constants/menu'
import { getTopicListAction } from './topicListAction'

// action creator
export const showMenuType = () => {
  return {
    type: SHOW_MENU
  }
}

export const hideMenuType = () => {
  return {
    type: HIDE_MENU
  }
}

export const changeMenuTitleName = (cate) => {
  return {
    type: CHANGE_MENU_TITLE,
    currentListItem: cate 
  }
} 

// dispatch action
export function showMenuAction(){
  return dispatch => {
    dispatch(showMenuType()) 
  }
}

export function hideMenuAction(){
  return dispatch => {
    dispatch(hideMenuType())
  }
}

export function changeMenuTitleAction(cate){
  return dispatch => {
    dispatch(changeMenuTitleName(cate))
    dispatch(getTopicListAction({tab: cate.key, page: 1, limit: 20}))
  }
}